<!--
 * @FilePath     : /study_code/layui/18-4.html
 * @Description  : id 配置项值，在其它 api 中使用
 * @Date         : 2025-04-10 16:01:03
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-10 16:01:11
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="/layui/dist/css/layui.css" />
  </head>
  <body>
    <button class="layui-button" id="btn">重新渲染树组件</button>
    <hr />

    <div id="test1"></div>

    <script src="/layui/dist/layui.js"></script>
    <script src="/layui/tree/common.js"></script>
    <script>
      layui.use('tree', function () {
        var tree = layui.tree,
          $ = layui.$

        //渲染
        var inst1 = tree.render({
          elem: elem,
          data: data,

          //
          id: 'theFirstTree',
        })

        // reload() api 使用 id 配置项配置的值
        $('#btn').on('click', function () {
          console.log('数字键重载')
          tree.reload('theFirstTree', {
            data: [],
          })
        })
      })
    </script>
  </body>
</html>
